package com.onLineCar.manages.web;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.onLineCar.common.core.domain.Result;
import com.onLineCar.manages.pojo.VehicleInfo;
import com.onLineCar.manages.pojo.dto.VehicleBaseInfoDTO;
import com.onLineCar.manages.pojo.request.VehicleInfoRequest;
import com.onLineCar.manages.service.VehicleInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 车辆基本信息表 前端控制器
 * </p>
 *
 * @author zhucaiyi
 * @since 2023-12-10
 */
@RestController
@RequestMapping("/vehicle-info")
public class VehicleInfoController {

    @Resource
    private VehicleInfoService vehicleInfoService;


    /**
     * 查询车辆基本信息
     *
     * @param vehicleInfoRequest
     * @return
     */
    @GetMapping("/queryVehicleInfo")
    public Result<IPage<VehicleInfo>> queryVehicleInfo(VehicleInfoRequest vehicleInfoRequest){
        return Result.success(vehicleInfoService.queryVehicleInfo(vehicleInfoRequest));
    }



    /**
     * 添加车辆基本信息
     * @param vehicleBaseInfoDTO
     * @return
     */
    @PostMapping("/addVehicleInfo")
    public Result<Boolean> addVehicleInfo(@RequestBody VehicleBaseInfoDTO vehicleBaseInfoDTO){
        return Result.success(vehicleInfoService.addVehicleInfo(vehicleBaseInfoDTO));
    }


    /**
     * 修改车辆基本信息
     * @param vehicleBaseInfoDTO
     * @return
     */
    @PostMapping("/updateVehicleInfo")
    public Result<Boolean> updateVehicleInfo(@RequestBody VehicleBaseInfoDTO vehicleBaseInfoDTO){
        return Result.success(vehicleInfoService.updateVehicleInfo(vehicleBaseInfoDTO));
    }

    /**
     * 查询车辆基本信息
     * @param vehicleId
     * @return
     */
    @GetMapping("/queryVehicleInfoByVehicleId/{vehicleId}")
    public Result<VehicleBaseInfoDTO> queryVehicleInfoByVehicleId(@PathVariable Integer vehicleId){
        return Result.success(vehicleInfoService.queryVehicleInfoByVehicleId(vehicleId));
    }


    @DeleteMapping("/deleteVehicleById/{id}")
    public Result<Boolean> deleteVehicleById(@PathVariable("id") Integer id) {
        return Result.success(vehicleInfoService.deleteVehicleById(id));
    }
}

